<?php
namespace app\admin\model;
use think\Model;
use think\Db;
class Subject extends Model
{
    /*查询科目，keyid=1 把id作为键值*/
    function subjectList($keyid=0){
        $subject_list = Db::name('subject')->order('subject_sort')->select();
        foreach($subject_list as $k=>$v){
            $subjectList[$v['subjectid']] = $v;
        }

        return $subjectList;
    }

    //处理参数
    function disposeData($data){
        $newData['subject_name'] = $data['subject_name'];
        $newData['art_type'] = $data['art_type'];

        return $newData;
    }

    function allSubjectList(){
        $res = Db::name("subject")->select();
        foreach($res as $k=>$v){
            $list[$v['subjectid']] = $v;
        }
        return $list;
    }

    //当前设置考试科目,并且当前学员类型可查看科目
    function userTestingSubjectList($testing_set=[],$art_type){
        $allSubjectList = $this->allSubjectList();
        foreach($testing_set as $k=>$v){
            //文科
            if($allSubjectList[$k]['art_type']==$art_type || $allSubjectList[$k]['art_type']==0){
                $subjectList[] = $allSubjectList[$k];
            }
        }
        return $subjectList;
    }

}